import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/7 15:36
 * @description DFS
 */
public class Solution2 {
    public static void main(String[] args) {

    }

    int max = Integer.MIN_VALUE;
    int res;

    public int findBottomLeftValue(TreeNode root) {
        dfs(root, 0);
        return res;
    }

    public void dfs(TreeNode root, int depth) {
        if (root == null) {
            return;
        }
        if (max < depth) {
            max = depth;
            res = root.val;
        }
        dfs(root.left, depth + 1);
        dfs(root.right, depth + 1);
    }
}
